<!--
 * @Description: 审核详情弹窗
 * @Author: liyujie
 * @Date: 2021/3/26
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/3/26
-->
<template>
    <div class="wrapper">
        <el-dialog
            :title="title"
            :visible.sync="dialogVisible"
            :close-on-click-modal="false"
            width="788px"
        >
            <div class="dialog-wrapper">
                <div class="result-view">
                    <div
                        class="result-title"
                        :style="{color: status === 'pass' ? '#2FBDB3' : '#F95B56'}"
                    >
                        <template v-if="status === 'pass'">审核通过</template>
                        <template v-if="status === 'reject'">审核未通过</template>
                        <template v-if="status === '' && fromType === -2">用户主动放弃任务</template>
                    </div>
                    <div
                        class="verify-reason"
                        v-if="status === 'reject' && reason"
                    >
                        未通过原因：{{ reason }}
                    </div>
                </div>
                <slot/>
            </div>
            <div
                slot="footer"
                class="footer-wrapper"
            >
                <div class="left">
                    <div
                        class="option-btn"
                        v-if="status === '' && fromType !== -2"
                        @click="$emit('pass')"
                    >
                        通过
                    </div>
                    <div
                        class="option-btn"
                        v-if="status === '' && fromType !== -2"
                        @click="$emit('reject')"
                    >
                        不通过
                    </div>
                </div>
                <div class="right">
                    <div
                        :class="`option-btn ${index === 0 ? 'disabled' : ''}`"
                        @click="$emit('change', 'prev')"
                    >
                        <i
                            class="el-icon el-icon-arrow-left"
                            style="margin-right: 4px"
                        />
                        查看上一条
                    </div>
                    <div
                        :class="`option-btn ${index === data.length -1 ? 'disabled' : ''}`"
                        @click="$emit('change', 'next')"
                    >
                        查看下一条
                        <i
                            class="el-icon el-icon-arrow-right"
                            style="margin-left: 4px"
                        />
                    </div>
                </div>
            </div>
        </el-dialog>
    </div>
</template>

<script>
export default {
    name: 'VerifyDialog',
    props: {
        title: {
            type: String,
            required: true
        },
        visible: {
            type: Boolean,
            default: false
        },
        data: {
            type: Array,
            default: () => {
                return [];
            }
        },
        index: {
            type: Number,
            default: 0
        },
        status: {
            type: String,
            default: ''
        },
        reason: {
            type: String,
            default: ''
        },
        fromType: {
            type: Number,
            default: 0
        }
    },
    computed: {
        dialogVisible: {
            get() {
                return this.visible;
            },
            set(val) {
                this.$emit('update:visible', val);
            }
        }
    },
    data() {
        return {};
    },
    mounted() {
    },
    methods: {
        /**
         * 审核
         * @param type
         */
        handleVerify(type) {
            this.$emit(type, this.verifyRow);
        }
    }
};
</script>

<style scoped lang="less">
.wrapper {
    .dialog-wrapper {
        .result-view {
            .result-title {
                font-size: 16px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                margin-bottom: 24px;
            }
            .verify-reason {
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #999999;
                margin-bottom: 12px;
            }
        }
    }
    /deep/ .el-dialog {
        border-radius: 0;
        .el-dialog__header {
            padding-top: 10px;
            box-shadow:0 1px 0 0 rgba(233,233,233,1);
            display: flex;
            align-items: center;
            background: #FAFAFA;
            border-radius: 4px 4px 0 0;
            .el-dialog__title {
                font-weight: 500;
                color: #333;
                font-size: 14px;
            }
            .el-icon-close:before {
                color: rgb(194,194,194);
                font-size: 17px;
                font-weight: bold;
            }
            .el-dialog__headerbtn {
                top: 14px;
            }
        }
        .el-dialog__body {
            padding: 24px 38px 0 58px;
        }
        .el-dialog__footer {
            padding: 0;
            height: 76px;
            display: flex;
            align-items: center;
            border-top: 1px solid #eee;
            .footer-wrapper {
                width: 100%;
                height: 100%;
                display: flex;
                align-content: center;
                justify-content: space-between;
                .left, .right {
                    display: flex;
                    align-items: center;
                    height: 100%;
                }
                .left {
                    border-right: 1px solid #f2f2f2;
                    .option-btn {
                        width: 182px;
                        height: 100%;
                        cursor: pointer;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        font-size: 14px;
                        font-family: PingFangSC-Medium, PingFang SC;
                        font-weight: 500;
                        user-select: none;
                        &:first-of-type {
                            color: #20A0FF;
                            position: relative;
                            &::after {
                                content: "";
                                display: block;
                                width: 1px;
                                height: 36px;
                                background: #F2F2F2;
                                position: absolute;
                                right: 0;
                                top: 50%;
                                transform: translateY(-50%);
                            }
                        }
                        &:hover {
                            background: #F2F2F2;
                            transition: all 0.4s;
                        }
                    }
                }
                .right {
                    .option-btn {
                        width: 124px;
                        height: 100%;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        font-size: 14px;
                        font-family: PingFangSC-Regular, PingFang SC;
                        font-weight: 400;
                        cursor: pointer;
                        user-select: none;
                        &:hover {
                            background: #F2F2F2;
                            transition: all 0.4s;
                        }
                        &.disabled {
                            color: #999999;
                        }
                    }
                }
            }
        }
    }

    /deep/ .el-textarea__inner {
        resize: none;
    }
}
</style>
